package com.hfkh.loop;

public class LoopDemo {

    public static void main(String[] args) {
        int i = 1;
        int oddSum = 0; //奇数和
        int evenSum = 0; //偶数和
        while (i <= 100) {
            if(i % 2 == 0){
                evenSum+=i;
            }
            else{
                oddSum+=i;
            }
            i++;
        }
        System.out.println("100以内（包括100）的偶数之和是:" + evenSum);

        evenSum = 0;
        int j = 1;
        do{
            if(j  %  2 == 0){
                evenSum += j;
            }
            j++;
        }while(j <= 100);
        System.out.println("100以内（包括100）的偶数之和是:" + evenSum);


        evenSum = 0;
        for (int k = 0; k <= 100 ; k++) {
            if(k % 2 == 0){
                evenSum += k;
            }
        }

        System.out.println("100以内（包括100）的偶数之和是:" + evenSum);
    }
}
